/**
 * 状态码
 * Created by Heiliuer on 2018/3/21 0021.
 */
const Koa = require('koa')
const app = new Koa()
const route = require('koa-route')

const _404_1 = ctx => {
    ctx.throw(404,'this is 404')// 404能带body
}
const _404_2 = ctx => {
    ctx.response.status = 404
    ctx.response.body = 'padg not found'// 响应body
    ctx.response.message  = '_404'
}


const _500 = ctx => {
    ctx.throw(500,'this is 500')// 500不能带消息
}



app.use(route.get('/41',_404_1))
app.use(route.get('/42',_404_2))
app.use(route.get('/5',_500))
app.listen(3000)


